More of the less disruptive Garmin changes...
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 30 Jan 2006 04:15:10 +0000 (04:15 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 30 Jan 2006 04:15:10 +0000 (04:15 +0000)
Fix polarity of test to allow lowercase letters to X series.
If waypoint is unknown on write for D109 or D110, tell the GPS that.
Improve readability of debugging code when generating unit ID headers.
Rework the product inquiry at startup.   Instead of fixed count,
read until error.
Display session req and request bulk packets when debugging protocol.

gpsbabel/garmin.c
gpsbabel/jeeps/gps.h
gpsbabel/jeeps/gpsapp.c

index 1e269960ac7fe41ec8689f4957389ea0c05e2e1f..a0c4be9d9c99e3a04b604dd35eb098b64967e081 100644 (file)
@@ -163,7 +163,7 @@ rw_init(const char *fname)
         * Until Garmins documents how to determine valid character space
         * for the new models, we just release this safety check manually.
         */
-       if (!receiver_must_upper)
+       if (receiver_must_upper)
                setshort_goodchars(mkshort_handle, valid_waypt_chars);
 
        setshort_mustupper(mkshort_handle, receiver_must_upper);
@@ -523,6 +523,7 @@ waypoint_write(void)
                }
                way[i]->smbl = icon;
                if (wpt->altitude == unknown_alt) {
+                       way[i]->alt_is_unknown = 1;
                        way[i]->alt = 0;
                } else {
                        way[i]->alt = wpt->altitude;
index 327b4e5651ffb3bec9541e70b3d639eef9869d53..7fd2ad701828eac412b83ebdd837caa5a6c2871b 100644 (file)
@@ -130,6 +130,7 @@ typedef struct GPS_SWay
     int32  colour;
     char   cc[2];
     UC     wpt_class;
+    UC     alt_is_unknown;
     float  alt;
     char   city[24];
     char   state[2];
index 488ad0f28239776734fda806af4e8b103541c180..a2f0d3bca50035d636417e9687f464a3942c82d8 100644 (file)
@@ -23,6 +23,7 @@
 ** Boston, MA  02111-1307, USA.
 ********************************************************************/
 #include "gps.h"
+#include "garminusb.h"
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
@@ -209,14 +210,11 @@ static int32 GPS_A000(const char *port)
     version = GPS_Util_Get_Short((rec->data)+2);
 
     (void) strcpy(gps_save_string,(char *)rec->data+4);
-    GPS_User((char *)rec->data+4);
-    (void) sprintf(tstr,"ID:\t\t%d\n",id);
     gps_save_id = id;
-    GPS_User(tstr);
     gps_save_version = (double)((double)version/(double)100.);
-    (void) sprintf(tstr,
-                  "Version:\t%.2f\n",gps_save_version);
-    GPS_User(tstr);
+
+    GPS_User("Unit:\t%s\nID:\t%d\nVersion:\t%.2f", 
+       gps_save_string, gps_save_id, gps_save_version);
 
 
     gps_date_time_transfer = pA600;
@@ -241,21 +239,30 @@ static int32 GPS_A000(const char *port)
     }
     else
     {
-        int maxct = 3;
+        int i;
        /*
         * The unit may return more than one packet, so read and
-        * discard all but the product inquiry response.
+        * discard all but the product inquiry response.  We have
+        * no way of knowing how many we'll get, so we have to keep
+        * reading until we incur a timeout.
         */
-       while (maxct--) {
-               (void) GPS_Packet_Read(fd, &rec);
-               GPS_Send_Ack(fd, &tra, &rec);
-               if (rec->type == 0xfd) {
-                       GPS_A001(rec);
-                       break;
-               }
+       for (i = 0; i < 25; i++) {
+           rec->type = 0;
+           
+           if (GPS_Packet_Read(fd, &rec) < 0) {
+                   goto carry_on;
+           }
+
+           GPS_Send_Ack(fd, &tra, &rec);
+
+           if (rec->type == 0xfd) {
+                   GPS_A001(rec);
+           }
        }
+       fatal("Failed to find a product inquiry response.\n");
     }
 
+carry_on:
     /* Make sure PVT is off as some GPS' have it on by default */
     if(gps_pvt_transfer != -1)
        GPS_A800_Off(port,&fd);
@@ -1998,7 +2005,11 @@ static void GPS_D109_Send(UC *data, GPS_PWay way, int32 *len, int protoid)
     p+=sizeof(int32);
     GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon));
     p+=sizeof(int32);
-    GPS_Util_Put_Float(p,way->alt);
+    if (way->alt_is_unknown) {
+       GPS_Util_Put_Float(p,1.0e25);
+    } else {
+       GPS_Util_Put_Float(p,way->alt);
+    }
     p+=sizeof(float);
     GPS_Util_Put_Float(p,way->dpth);
     p+=sizeof(float);
@@ -5290,7 +5301,6 @@ time_t GPS_A600_Get(const char *port)
     if(!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New()))
        return MEMORY_ERROR;
 
-
     GPS_Util_Put_Short(data,
                       COMMAND_ID[gps_device_command].Cmnd_Transfer_Time);
     GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data,
@@ -6021,5 +6031,11 @@ Get_Pkt_Type(unsigned char p, unsigned char d0, const char **xinfo)
                return "PRDREQ";
        if (p == LT.Pid_Product_Data)
                return "PRDDAT";
+       if (p == GUSB_REQUEST_BULK) 
+               return "REQBLK";
+       if (p == GUSB_SESSION_START)
+               return "SESREQ";
+       if (p == GUSB_SESSION_ACK)
+               return "SESACK";
        return "UNKNOWN";
 }